package com.happy3w.ssp.schoolmatehome.component;

import jakarta.annotation.PostConstruct;
import lombok.RequiredArgsConstructor;
import org.springframework.context.ApplicationContext;
import org.springframework.stereotype.Component;
import org.springframework.web.servlet.mvc.method.annotation.RequestMappingHandlerMapping;

@RequiredArgsConstructor
@Component
public class MappingLogger {

    private final ApplicationContext applicationContext;

    @PostConstruct
    public void logMappings() {
        RequestMappingHandlerMapping mapping = applicationContext.getBean(RequestMappingHandlerMapping.class);
        mapping.getHandlerMethods().forEach((key, value) -> {
            System.out.println("Mapped: " + key + " -> " + value);
        });
    }
}